<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Assign extends Controller {
    private $current_year,$user_id;
    function Assign() {
        parent::Controller();
        //$this->dx_auth->check_uri_permissions();
        $this->load->model('m_assign');
        $this->load->library('form_validation');
        $this->load->library('upload');
        $this->current_year=$this->session->userdata('year_id');
        $this->user_id=$this->session->userdata('user_id');
    }

    function index() {
        
        
    }

/* -----------------------------教师部分功能-----------------------------------*/

    //选择修改课业
    function editassign() {
        $this->load->view('teacher/editassign');
    }

    //添加新课业
    function addassign() {
    //获取信息
        $data['class']  =   $this->m_assign->get_class();
        $data['course'] =   $this->m_assign->get_class_by_year_and_teacher($this->user_id, $this->current_year);
        //设置验证规则
        $this->form_validation->set_rules('assignname', 'Assignname', 'required');
        if ($this->form_validation->run()) {
            $assignname = $this->input->POST('assignname');
            $assigninfo = $this->input->POST('assigninfo');
            $courseid   = $this->input->POST('courseid');
            $classid    = $this->input->POST('classeid');
            $createtime = $this->input->POST('createtime');
            $closetime  = $this->input->POST('closetime');
            //$data['assignfile'] = $this->input->POST('assignfile');

            $this->m_assign->addassign($assignname,$assigninfo,$courseid,$classid,$createtime,$closetime);
            $this->load->view('teacher/addassign');
        } else {
            $this->load->view('teacher/addassign',$data);
        }

    }

    //上传课业布置文件
    function upload_assignfile() {
        $upload_path = '';
        $this->upload->do_upload($upload_path);
    }


}
?>